{{template "base/base.html" .}}
{{define "head"}}<title>Go Walker - {{i18n .Lang "Function"}}</title>{{end}}
{{define "body"}}
<div>
	{{template "base/alert.html" .}}
    <div>
        <h1>{{i18n .Lang "Function"}}</h1>
        <form class="form-inline" action="/function">
            <div class="form-group col-md-6">
                <input class="form-control" type="text" placeholder="{{i18n .Lang "Type keywords to search"}}" name="q" value="{{.Keyword}}" style="position: relative; display: inline-block; direction: ltr;">
            </div>
            <button class="btn btn-success btn-lg" style="border-radius: 0px;" type="submit"><i class="icon-search"></i> {{i18n .Lang "Let's go!"}}</button>
        </form>
        <br>

        {{if .IsFindFunc}}
        <table name="result_table" class="table table-hover">
            <thead>
                <tr>
                    <th>{{i18n .Lang "Function name"}}</th>
                    <th>{{i18n .Lang "Import Path"}}</th>
                    <th>
                        {{i18n .Lang "Synopsis"}} 
                        <small class="text-info">{{i18n .Lang "Hover see more"}}.</small>
                    </th>
                </tr>
            </thead>

            <tbody>
                {{range .Results}}
                <tr>
                    <td>{{.Name}}</td>
                    <td><a href="/{{.Path}}#{{.Name}}">{{.Path}}</a></td>
                    <td>{{.Doc}}</td>
                </tr>
                {{end}}
            </tbody>
        </table>

        <script>
            (function () {
                var tables = document.getElementsByName("result_table");
                var now = new Date();
                for (var n = 0; n < tables.length; n++) {
                    var table = tables[n];
                    var items = table.getElementsByTagName("tr");
                    for (var i = 1; i < items.length; i++) {
                        var s = table.rows[i].cells[1].getElementsByTagName("a")[0];
                        if (s.innerHTML.length > 40) {
                            s.title = s.innerHTML;
                            s.innerHTML = "..." + s.innerHTML.substr(s.innerHTML.length - 37);
                        }
                        // Limit length.
                        s = table.rows[i].cells[2];
                        if (s.innerHTML.length > 65) {
                            s.title = s.innerHTML;
                            s.innerHTML = s.innerHTML.substr(0, 65) + "...";
                        }
                    }
                }
            })();
        </script>
        {{else}}

        {{if .IsShowIntro}}
        <p>{{i18n .Lang ".Type keyword to search tens of thousands of functions."}}</p>
        {{else}}
        <p>{{i18n .Lang ".No functions found."}}</p>
        {{end}}

        {{end}}
    </div>
</div>
{{end}}
